package com.weasing.res.utils;

import java.util.ArrayList;
import java.util.List;

public class DicUtils {
	/**
	 * 将string（数据字典表中查询结果）变为List
	 */
	public static List<String> string2List(String str) {
		str = str.substring(3, str.length());
		List<String> list = new ArrayList<String>();
		String[] strs = (str.trim()).split("\\|");
		if (strs.length > 0) {
			for (int i = strs.length - 1; i >= 0; i--) {
				list.add(strs[i]);
			}
		}
		return list;
	}

	/**
	 * 把list<string> 变成字典文件里面的字段 进行编辑
	 * 
	 * @author 黄龙
	 * @param str
	 * @return
	 */
	public static String list2String(List<String> list) {
		StringBuffer sb = new StringBuffer("@@");
		if (null != list) {
			for (String string : list) {
				sb.append("|" + string);
			}
		}
		return sb.toString();

	}

}
